Software Development
Building HTTP APIs Using Molten
Molten Framework: Advanced Features
Molten Framework: Building HTTP APIs

Molten Framework: Advanced Features

Course Number:
it_pyhtamdj_02_enus
Lesson Objectives

Molten Framework: Advanced Features

  • discover the key concepts covered in this course
  • connect to a SQLite database using the python sqlite3 library and define SQL queries to run against that database from your Molten app
  • wire up your Molten application so that the data passed in through POST requests is written out to a SQLite database
  • read data from a database when a GET request is submitted to your Molten app
  • add a middleware layer into your app to verify authorization information in HTTP request headers
  • define a middleware layer which distinguishes between requests when checking for authorization
  • create an OpenAPIHandler instance which dynamically generates documentation for your Molten application
  • use the OpenAPIUIHandler class to generate a Swagger UI for your Molten application
  • use Molten's HTTPSecurityScheme to enable the use of authorization from the Swagger UI
  • build a Molten application which returns an HTTP Response containing binary data
  • summarize the key concepts covered in this course

Overview/Description
This course covers the use of features in the Molten framework to make your HTTP APIs meaningful and easy to use and test. You'll begin by connecting your Molten application to a SQLite database, including the creation of a cursor to work with the database. You'll then wire up your app so that all the data sent in using POST requests to a specific route is written out to the database. You'll also define handlers for GET requests for that same data by reading from the database. Next, you'll then look at adding middleware into your app and set this middleware to check request headers for the authorization to invoke requests. You'll also tweak the middleware to distinguish between certain types of requests so that authorization is only required for some of them. You'll also see how you can dynamically generate documentation for your Molten application using the OpenAPIHandler. You'll explore how you can use the OpenAPIUIHandler to produce a Swagger UI, which can be used by developers to test the application and also by users to figure out exactly how to use your APIs. Finally, you'll learn how you can serve images to clients using Molten, including attaching a local file to a Response object and returning it to the client.

Target

Prerequisites: none

Molten Framework: Building HTTP APIs

Course Number:
it_pyhtamdj_01_enus
Lesson Objectives

Molten Framework: Building HTTP APIs

  • discover the key concepts covered in this course
  • create a virtual environment from which Molten REST APIs can be run and install various libraries such as Molten, Pytest, and JQ
  • develop a basic Molten app with a single route that takes in a query parameter with a QueryParam instance and returns a value based on that parameter
  • build a Molten app that takes in URL parameters
  • define an integer URL parameter and verify your app's behavior when it comes to handling such data types and develop a Molten test with pytest
  • develop some basic tests to verify the behavior of your Molten application
  • use a Molten Schema instance to validate the POST data submitted to your app
  • submit JSON data in a POST request and verify that your schema definitions work correctly
  • use a forward reference to another schema within a schema definition
  • use the load_schema function to convert a Python dictionary to a schema object and use the is_schema function to check whether an object is a schema instance
  • use the dump_schema function to convert a schema object to a Python dictionary
  • define the settings for your app by loading a dictionary into the Molten SettingsComponent
  • load the settings defined in a JSON file in your file system into a Molten SettingsComponent instance
  • create a .TOML file that contains settings for a Molten app and read in that file using a TOMLSettingsComponent instance
  • summarize the key concepts covered in this course

Overview/Description
This course introduces you to a breadth of features available in the Molten framework to help you build HTTP APIs. You'll begin by creating a virtual environment, installing Molten and various other libraries such as Pytest to test out your Molten apps, and installing Gunicorn to serve your apps. You'll then move on to creating REST APIs using the Molten framework. You'll create a very basic REST API with only one route that maps to a function and the API to process an HTTP GET request. You'll also explore the use of a QueryParam object to handle query parameters passed in an HTTP request. You'll next test your Molten APIs using Pytest by writing some simple tests to ensure an HTTP 200 status code is returned when a correct request is sent to the server and an error code is returned with the response otherwise. You'll also learn how these tests can be executed and how to analyze their outputs. You'll learn about the processing of POST requests, how to ensure the validity of POST data using a Molten Schema instance, different ways to define a schema, and how to use a forward reference. You'll explore the built-in objects available in the Molten framework and how to pass in a plain Python dictionary containing settings for an app. Finally, you'll see how settings can be saved in an external JSON file and then imported into a Molten app and how to load settings defined within a TOML file.

Target

Prerequisites: none

Close Chat Live